#/bin/bash
mysql_db_con=`/bin/netstat -aetp |grep mysqld|grep ESTABLISHED|awk '{print $5}'|wc|awk '{print $1}'`

log_path='/usr/lib64/nagios/plugins/output/check_mysql_connects.log'

if [ $mysql_db_con -gt 1000 ]
then
	echo "2;mysql connections exceeds 1000" > $log_path
	exit 2
else
	echo "0;the number of mysql connection reachs $mysql_db_con" > $log_path
	exit 0
fi
